// pages/shop/shop-details/shop-details.js
var httpUtil = require('../../../utils/httpUtil.js');
var uiUtil = require('../../../utils/uiUtil.js');
var util = require('../../../utils/util.js');
const app = getApp();
var that;

Page({

  /**
   * 页面的初始数据
   */
  data: {
    mchProductInfo:null //商家菜品详情信息
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    that = this;
    wx.setNavigationBarTitle({
      title: options.mchName
    });
    that.searchMchProductInfo(options);
  },

  /**
   * 转发分享设置
   */
  onShareAppMessage: function (res) {
    return util.handleShareApp('shop-details', that.data.mchProductInfo);
  },

  /**
   * 商家菜品详情查询
   */
  searchMchProductInfo: function (options){
    httpUtil.PostRequest("searchMchProductInfo", {
      mchId: options.mchId,
      productId: options.id
    }, {
      success(res) {
        that.setData({
          mchProductInfo: res
        });
      },
      fail(code, res) {
        uiUtil.showToast(res);
      },
      complete() { }
    })
  }

})